package com.adee.primary.t01_arr;

import com.adee.util.Util;

import java.util.Arrays;
import java.util.Scanner;

/**
 * 旋转数组
 */
public class T003 {
    public static void main(String[] args) {
        test1();
    }

    // 解法一
    public static void test1() {
        // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
        Scanner in = new Scanner(System.in);
        while (in.hasNextLine()) {
            // 读取一行
            String s = in.nextLine();
            String[] arr = s.split("[\\s,]");
            int[] ints = Arrays.stream(arr).mapToInt(Integer::parseInt).toArray();
            int len = ints.length;
            int k = Integer.parseInt(in.nextLine());
            int n = k % len;
            int[] temp = new int[len];
            int pos = 0;
            for (int i = 0; i < len; i++) {
                pos = i + n >= len ? i+n-len : i+n;
                temp[pos] = ints[i];
            }
            Util.print(ints);
            Util.print(temp);
        }
    }

    // 解法二
    public static void test2() {
        // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
        Scanner in = new Scanner(System.in);
        while (in.hasNextLine()) {
            // 读取一行
            String s = in.nextLine();
            String[] arr = s.split("[\\s,]");
            int[] ints = Arrays.stream(arr).mapToInt(Integer::parseInt).toArray();
            int len = ints.length;
            int k = Integer.parseInt(in.nextLine());
            int n = k % len;
            int[] temp = new int[len];
            int pos = 0;
            for (int i = 0; i < len; i++) {
                pos = i + n >= len ? i+n-len : i+n;
                temp[pos] = ints[i];
            }
            Util.print(ints);
            Util.print(temp);
        }
    }
}
